import { http } from "@/utils/http";
import { baseUrlApi } from "./utils";

type Result = {
  success: boolean;
  data?: {
    /** 列表数据 */
    list: Array<any>;
    total: number;
    pageSize: number;
    currentPage: number;
  };
};

/** 获取视频列表 */
export const getVideoList = (params?: object) => {
  return http.request<Result>("get", baseUrlApi("video/list"), { params });
};

/** 添加视频 */
export const addVideo = (data?: object) => {
  console.log("addVideo curData:", data);
  return http.request<Result>("post", baseUrlApi("video/add"), { data });
};

/** 修改视频 */
export const updateVideo = (data?: object) => {
  console.log("updateVideo curData:", data);
  return http.request<Result>("post", baseUrlApi("video/update"), { data });
};

/** 删除视频 */
export const deleteVideo = (data?: object) => {
  console.log("deleteVideo curData:", data);
  return http.request<Result>("post", baseUrlApi("video/delete"), { data });
};

/** 向 本地m3u8 API推送数据 */
export const sendVideo = (host, data?: object) => {
  console.log("sendVideo curData:", data);
  return http.request<any>("post", host, { data });
};

/** 向 远程m3u8 API推送数据 */
export const postVideo = (data?: object) => {
  console.log("postVideo curData:", data);
  return http.request<any>("post", "/remotom3u8", { data });
};

/** 向 远程m3u8 API推送数据 */
// request("http://127.0.0.1:880/?search=" + AVID + "%20" + extend + "&json=1");
export const getExist = (params?: string) => {
  console.log("getexist curData:", params);
  return http.request<Result>("get", params);
};
